package com.bw.merchant.page

import android.graphics.Color
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.base.path.RouterPath
import com.bw.common.view.BaseMvvmActivity
import com.bw.merchant.R
import com.bw.merchant.databinding.ActivityApplicationBinding
import com.bw.merchant.page.fragment.RecordingFragment
import com.bw.merchant.page.fragment.SettledFragment
import dagger.hilt.android.AndroidEntryPoint

/**
 * 入驻申请页面
 */
@Route(path = RouterPath.PATH_SETTLED_PATH)
@AndroidEntryPoint
class ApplicationActivity : BaseMvvmActivity<ActivityApplicationBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_application

    override fun initViews() {
        mDataBinding.approvalBack.setOnClickListener {
            finish()
        }
        mDataBinding.approval.setOnClickListener {
            ARouter.getInstance().build(RouterPath.PATH_APPROVAL_PATH).navigation()
        }
        //默认是入驻申请页面
        replaceFragment(SettledFragment())

        //设置点击事件
        mDataBinding.merchantApplications.setOnClickListener { v ->
            mDataBinding.merchantApplications.setTextColor(Color.parseColor("#007660"))
            mDataBinding.merchantApplicationsInd.setBackgroundResource(R.drawable.ind_select)


            mDataBinding.merchantRecord.setTextColor(Color.parseColor("#000000"))
            mDataBinding.merchantRecordInd.setBackgroundResource(R.drawable.ind_unselect)
            replaceFragment(SettledFragment())
        }

        mDataBinding.merchantRecord.setOnClickListener { v ->
            mDataBinding.merchantApplications.setTextColor(Color.parseColor("#000000"))
            mDataBinding.merchantApplicationsInd.setBackgroundResource(R.drawable.ind_unselect)


            mDataBinding.merchantRecord.setTextColor(Color.parseColor("#007660"))
            mDataBinding.merchantRecordInd.setBackgroundResource(R.drawable.ind_select)
            replaceFragment(RecordingFragment())
        }
    }
    private fun replaceFragment(fragment: Fragment) {
        supportFragmentManager.beginTransaction()
            .replace(R.id.fragment, fragment)
            .commit()
    }

}